import {createSlice} from '@reduxjs/toolkit'

export const counterSlice = createSlice({
  name: 'counter',
  initialState: {
    count: 0,
    label: '哈哈哈'
  },
  reducers: {
    increment: (state) => {
      state.count += 1
    },
    decrement: (state) => {
      state.count -= 1
    },
    incrementByAmount: (state, action) => {
      // payload：传入的数据
      state.count += action.payload
    }
  }
})

export const {increment, decrement, incrementByAmount} = counterSlice.actions

export default counterSlice.reducer
